import { deepCopy } from '@delon/util'
import { Injectable } from '@angular/core'

import { ObservableStore } from '@shared/classes/ObservableStoreClass'
import { Acquirer } from '@shared/interfaces/acquirer'

@Injectable()
export class AcquirerStoreService extends ObservableStore<Acquirer> {
  constructor() {
    super(new Acquirer())
  }

  // TODO， 多级嵌套更新，不能直接这样全部赋值，会将一些值覆盖掉
  updateValue(acquirer: Acquirer): void {
    const value = deepCopy(this.value)
    Object.assign(value, acquirer)
    this.setValue(value)
  }

  reset(): void {
    this.setValue(new Acquirer())
  }
}
